package com.easthome.process.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.easthome.common.result.Result;
import com.easthome.model.process.ProcessTemplate;
import com.easthome.model.process.ProcessType;
import com.easthome.process.mapper.ProcessTypeMapper;
import com.easthome.process.service.ProcessTemplateService;
import com.easthome.process.service.ProcessTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @author: 朱敦宇
 * @time: 2023/11/15 12:22
 */
@Service
public class ProcessTypeServiceimpl extends ServiceImpl<ProcessTypeMapper, ProcessType> implements ProcessTypeService {
    @Autowired
    private ProcessTemplateService processTemplateService;
    @Override
    public Result findProcessType() {
        List<ProcessType> processTypeList = baseMapper.selectList(null);
        for (ProcessType processType : processTypeList) {
            LambdaQueryWrapper<ProcessTemplate> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.eq(ProcessTemplate::getProcessTypeId,processType.getId());
            List<ProcessTemplate> list = processTemplateService.list(queryWrapper);
            processType.setProcessTemplateList(list);
        }
        return Result.ok(processTypeList);
    }
}
